package com.fiap.to;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "AM_EMAIL")
public class EmailTO implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GenericGenerator(name = "seq_email", strategy = "increment")
	@GeneratedValue(generator = "seq_email")
	@Column(name = "ID_EMAIL")
	private int id_email;
	@Column(length = 20)
	private String email;
	@ManyToOne(cascade=CascadeType.PERSIST)
	@JoinColumn(name = "ID_PESSOA")
	private PessoaTO pessoa;

	@PrePersist
	private void executaAntesDePersistir() {
		System.out.println("Persistindo...");
	}

	public EmailTO(int id_email, String email, PessoaTO pessoa) {
		super();
		this.id_email = id_email;
		this.email = email;
	}

	public EmailTO() {
		super();
		// TODO Auto-generated constructor stub
	}

	public int getId_email() {
		return id_email;
	}

	public void setId_email(int id_email) {
		this.id_email = id_email;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public PessoaTO getPessoa() {
		return pessoa;
	}

	public void setPessoa(PessoaTO pessoa) {
		this.pessoa = pessoa;
	}

}
